import Vue from 'vue'
//skywalking监控系统
import ClientMonitor from 'skywalking-client-js';
//注册skywalking
ClientMonitor.register({
  service: 'test1',//应用名称
  serviceVersion:'2.0.1',//应用版本号
  traceSDKInternal:true,//追踪sdk
  pagePath: location.href,//当前路由地址
  useFmp: true,
  vue:Vue,//vue实例
});


import 'normalize.css/normalize.css'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

import '@/styles/index.scss'
import '@/assets/icons/iconfont.css'

import App from './App'
import store from './store'
import router from './router'

import '@/icons'
import '@/permission'

import perms from '@/directive/permission'
import flowPerms from '@/directive/flow'

import { getDicts } from '@/api/system/dict'
import { getConfigKey } from '@/api/system/config'
import { selectDictLabel } from '@/utils/data-process'

import VCharts from 'v-charts-v2'

// 字典数据组件
import DictData from '@/components/DictData'
// 字典标签组件
import DictTag from '@/components/DictTag'
// 自定义表格工具组件
import RightToolbar from "@/components/RightToolbar"
import { parseTime, resetForm} from "@/utils/common";
// 富文本组件
import Editor from "@/components/Editor"

Vue.prototype.getDicts = getDicts
Vue.prototype.getConfigKey = getConfigKey
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.resetForm = resetForm
Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.parseTime = parseTime


// 全局组件挂载
Vue.component('DictTag', DictTag)
Vue.component('RightToolbar', RightToolbar)
Vue.component('Editor', Editor)

Vue.use(ElementUI)
Vue.use(perms)
Vue.use(flowPerms)
Vue.use(VCharts)

DictData.install()

Vue.config.productionTip = false

new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})
// Vue 报错上报到skywalking。
Vue.config.errorHandler = (error) => {
  console.error(error);
  reportFrameErrors(error);
}
//监听ajax报错
window.addEventListener('error', error=>{
  console.log("error--->",error)
  reportFrameErrors(error);
}, true);
//上报错误信息方法
function reportFrameErrors(error){
  ClientMonitor.reportFrameErrors({
    service: 'test1',//应用名称
    serviceVersion:'2.0.1',//应用版本号
    pagePath:  location.href,
    vue:Vue,
  }, error);
}

